<div class=index>

	<h2><?php echo __('Mensagens não lidas')?></h2>

<?php $projetoId = 0; ?>
<?php $tarefaId = 0; $numMensagens = 0;?>
<?php foreach($mensagens as $item){
	if($projetoId != $item['Tarefa']['projetos_id'])
		$projetoId = 0;
	
	if($projetoId == 0){
		if($tarefaId != 0){?>
		
			<span class="tarefa_nao_lido">
				<?php echo $this->Html->link(__('Tarefa ').$tarefas[$tarefaId].' - '. $numMensagens.__(' mensagens'),'/tarefas/view/'.$tarefaId); ?>
			</span>
			
			<?php $tarefaId = 0;
			$numMensagens = 0;
		}
		$projetoId = $item['Tarefa']['projetos_id']; ?>
		
		<span class="projeto_nao_lido"><?php echo __('Projeto ').$projetos[$projetoId]."<BR>"; ?></span>
		
	<?php 
	}
	
	if($tarefaId != $item['Tarefa']['id_tarefas'] && $tarefaId != 0){?>
		<span class="tarefa_nao_lido">
			<?php echo $this->Html->link(__('Tarefa ').$tarefas[$tarefaId].' - '. $numMensagens.__(' mensagens'),'/tarefas/view/'.$tarefaId); ?>
		</span>
		
		<?php $tarefaId = 0;
		$numMensagens = 0;
	}
	
	if($tarefaId == 0){
		$tarefaId = $item['Tarefa']['id_tarefas'];	
		
	}
	$numMensagens++;
?>
<?php }?>

	<span class="tarefa_nao_lido">
		<?php echo $this->Html->link(__('Tarefa ').$tarefas[$tarefaId].' - '. $numMensagens.__(' mensagens'),'/tarefas/view/'.$tarefaId); ?>
	</span>
	
</div>